package com.sunni.service.impl;

import com.sunni.entity.Admin;
import com.sunni.entity.Reader;
import com.sunni.repository.AdminRepository;
import com.sunni.repository.ReaderRepository;
import com.sunni.repository.impl.AdminRepositoryImpl;
import com.sunni.repository.impl.ReaderRepositoryImpl;
import com.sunni.service.LoginService;
import org.junit.Test;

public class LoginServiceImpl implements LoginService {

    ReaderRepository readerRepository  = new ReaderRepositoryImpl();
    AdminRepository adminRepository = new AdminRepositoryImpl();

    @Test
    public void main() {
        System.out.println("LoginService: "+adminRepository.login("juzuo","1555523"));
    }

    @Override
    public Object login(String username,String password, String type) {
        Object object = null;
        switch (type){
            case "reader":
                object = readerRepository.login(username,password);
                break;
            case "admin":
                object = adminRepository.login(username,password);
                break;
        }
        return object;
    }

}
